// custom-tab-bar/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    
  },

  /**
   * 组件的初始数据
   */
  data: {
    
    selected:0,
    color: "#6e6d6b",
    selectedColor:"#000000",
    list: [
      {
        "pagePath": "/pages/main-buy/buy",
        "iconPath": "../images/dewu/buy.png",
        "selectedIconPath": "../images/dewu/buy1.png",
        text: "购买"
      },
      {
        "pagePath": "/pages/main-query/query",
        "iconPath": "../images/dewu/query.png",
        "selectedIconPath": "../images/dewu/query1.png",
        text: "鉴别查询"
      },
      {
        pagePath: "/pages/main-wash/wash",
        iconPath: "../images/dewu/wash.png",
        selectedIconPath: "../images/dewu/wash1.png",
        text: "洗护"
      },
      {
        "pagePath": "/pages/main-my/my",
        "iconPath": "../images/dewu/my.png",
        "selectedIconPath": "../images/dewu/my1.png",
        text: "我"
      }
    ]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    switchTab(e) {
      const data = e.currentTarget.dataset
      const url = data.path
      let app = getApp();
      app.data.sourcePagePath = this.data.list[this.data.selected].pagePath; // 跳转之前记录跳转前的页面路径；
      wx.switchTab({
        url:url
      })
      this.setData({
        selected: data.index
      })
    }

    

  },
  /*
  * lifetimes 里写的是组件生命周期函数
  */ 
  lifetimes:{
    created:function(){
      let app = getApp();
      // console.log(app.data.sourcePagePath);
    }
  }


})
